package com.zx.kitchen.index.common.mvp.presenter;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zx.kitchen.index.common.entity.BusinessReportTotalBean;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.mvp.model.BusinessReportModelImpl;
import com.zx.kitchen.index.common.mvp.model.PurchaseReportModelImpl;
import com.zx.kitchen.index.common.mvp.view.BusinessReportView;

/**
 * Created by Administrator on 2017/3/13.
 */

public class PurchaseReportPresenter implements OnResultListener {
    private Context context;
    private PurchaseReportModelImpl purchaseReportModel;
    private BusinessReportView businessReportView;


    public PurchaseReportPresenter(Context context, BusinessReportView businessReportView) {
        this.context = context;
        this.businessReportView = businessReportView;
        purchaseReportModel = new PurchaseReportModelImpl();
    }

    public void getDataFromNet(String type ,String start_time,String end_time){
        purchaseReportModel.getFromNet(1,context,type,start_time,end_time,this,null);
    }

    @Override
    public void onSuccess(int requestCode, String str) {
        BusinessReportTotalBean businessReportTotalBean = JSON.parseObject(str, new TypeReference<BusinessReportTotalBean>() {
        });
        businessReportView.onSuccess(businessReportTotalBean);
    }

    @Override
    public void onFailure(int requestCode, String str) {
        businessReportView.onFail(str);
    }
}
